package com.wy.controller;

import com.wy.Service.ResideService;
import com.wy.pojo.Danyuan;
import com.wy.pojo.Reside;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/reside")
@CrossOrigin
public class ResideController {
    @Resource
    private ResideService resideServer;
    String msg;

    @GetMapping("/list")
    public List<Reside> search(){
        return resideServer.searchAll();
    }



    @GetMapping("/delete")
    public String delete(Integer id){
        try{
            resideServer.del(id);
            msg="删除成功";
        }catch (Exception e){
            msg="删除失败";
        }
        return msg;
    }

    @GetMapping("/add")
    public String add(Reside reside){
        try{
            resideServer.add(reside);
            msg="添加成功";
        }catch (Exception e){
            msg="添加失败";
        }
        return msg;
    }
    @GetMapping("/update")
    public String update(Reside reside){
        try{
            resideServer.add(reside);
            msg="修改成功";
        }catch (Exception e){
            msg="修改失败";
        }
        return msg;
    }
}
